import 'package:flutter/material.dart';

class GridViewBuilderCase extends StatelessWidget {
  const GridViewBuilderCase({super.key});
  @override
  Widget build(BuildContext context) {
    return GridView.builder(
      itemCount: 10,
      gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
        crossAxisCount: 2,//一行的数量
        mainAxisSpacing: 10,//主轴间距
        crossAxisSpacing: 10,//交叉轴间距
        childAspectRatio: 2/1,//子项的宽高比
      ),
      itemBuilder: (context, index) {
        return Container(
          color: Colors.primaries[index],
        );
      },
    );
  }
}